﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ComputerResourceConsole.lib;
using ComputerResourceConsole.factory;
using ComputerResourceConsole.common;

namespace ComputerResourceConsole.control
{
    public class ContainerAdvancedControl : ComponentControl, IContainerAdvancedControl
    {
        private IContainerOpera _pContainOpera = null;
        private string _strArgs = "";

        public ContainerAdvancedControl()
            : base()
        {
            this._pContainOpera = ComponentOperaFactory.createContainerOpera();
            this._pContainOpera.FilePath = this._pConfig.NodejsPath;
        }

        public string Arguments
        {
            get
            {
                return this._strArgs;
            }
            set
            {
                this._strArgs = value;
            }
        }


        public int start(CommonMethod.CommonEvent exit)
        {
            this._pContainOpera.EntryPath = this.Arguments;
            this._status = "Started";
            return this._pContainOpera.start(exit);
        }

        public int stop()
        {
            this._status = "Stopped";
            return this._pContainOpera.stop();
        }

        public int restart(CommonMethod.CommonEvent exit)
        {
            this._pContainOpera.stop();
            int flag = this._pContainOpera.start(exit);
            this._status = "Started";
            return flag;
        }
    }
}
